﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;

namespace AutoSendMail
{
    public partial class MainForm : Form
    {
        private log4net.ILog log = log4net.LogManager.GetLogger("ValuesController");
        public MainForm()
        {
            InitializeComponent();
            string Hour = ConfigurationManager.AppSettings["Hour"];
            textBox2.Text = Hour;
            string Minute = ConfigurationManager.AppSettings["Minute"];
            textBox3.Text = Minute;
            string Toadd = ConfigurationManager.AppSettings["Toadd"];
            textBox1.Text = Toadd;
            string Sql = ConfigurationManager.AppSettings["Sql"];
            textBox4.Text = Sql;

        }
        private void Button1_Click(object sender, EventArgs e)
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.AppSettings.Settings["Hour"].Value = textBox2.Text;
            config.AppSettings.Settings["Minute"].Value = textBox3.Text;
            config.AppSettings.Settings["Toadd"].Value = textBox1.Text;
            config.AppSettings.Settings["Sql"].Value = textBox4.Text;
            config.Save(ConfigurationSaveMode.Full);
            ConfigurationManager.RefreshSection("appSettings");
            log.Info("保存新发送参数!");
        }

        private void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }
    }
}
